﻿<template>
    <div class="twoPublic">
        <Card :bordered="false">
            <p slot="title">
                发布公示
            </p>
        <Form ref="publicity" :model="publicity" :rules="ruleValidate">
            <FormItem prop="Title">
            <Row style="margin:20px 0 10px 0">
                <Col span="24">
                <Input v-model="publicity.Title" placeholder="标题（项目名称+环境影响评价第一次信息公示/第二次信息公示、环境影响报告表/报告书全本公示、竣工环境保护验收公示等）" />
                </Col>
            </Row>
            </FormItem>
            <Row style="position:relative;z-index:1001">
                <Col class="other-Col" span="24">
                <Row>
                    <Col span="3">
                    <FormItem prop="ProjectType">
                    <Select placeholder='项目类型' v-model="publicity.ProjectType" style="width:100%;" @on-change="changeType">
                        <Option v-for="item in projectType" :value="item.value" :key="item.value">{{ item.label }}</Option>
                    </Select>
                    </FormItem>
                    </Col>
                    <Col span="3" offset="1">
                    <FormItem prop="ReportType">
                    <Select placeholder='报告类型' v-model="publicity.ReportType" style="width:100%">
                        <Option v-for="item in reportType" :value="item.value" :key="item.value">{{ item.value }}</Option>
                    </Select>
                    </FormItem>
                    </Col>
                </Row>
                </Col>
            </Row>
            <Row style="position:relative;z-index:1000;">
                <Col span="3">
                <FormItem prop="MProvince">
                    <Select placeholder='省份' v-model="publicity.MProvince" style="width:100%" @on-change="change">
                        <Option v-for="item in cityList" :value="item.name" :key="item.name">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                </Col>
                <Col span="3" offset="1">
                <FormItem prop="MCity">
                    <Select placeholder='城市' v-model="publicity.MCity" style="width:100%" @on-change="changeCounty">
                        <Option v-for="item in cities" :value="item.name" :key="item.name">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                </Col>
                <Col span="3" offset="1">
                <FormItem prop="MCounty">
                    <Select placeholder='县区' v-model="publicity.MCounty" style="width:100%">
                        <Option v-for="item in countys" :value="item" :key="item">{{ item }}</Option>
                    </Select>
                </FormItem>
                </Col>
                <Col span="12" offset="1">
                <!-- <FormItem prop="MAddress"> -->
                    <Input v-model="publicity.MAddress" placeholder="详细地址" />
                <!-- </FormItem> -->
                </Col>
            </Row>
            <UE :defaultMsg='ueditor.defaultMsg'  :config='ueditor.config' ref="ue"></UE>
            <div style="padding: 15px 0 0 10px;text-align:left;">
                <Upload ref="upload"
                        multiple
                        with-credentials
                        :action="shishi + 'fileUpload/uploadAvatar2'"
                    :default-file-list="defaultList"
                    :on-success='uploadSuccess'
                    :on-remove='removeFile'
                    :on-error='uploadError'
                    :data='{Id: publicity.FileID?publicity.FileID:fileID,Key:"Enclosure"}'>
                    <Button icon="ios-cloud-upload-outline">附件上传</Button>
                </Upload>

            </div>
            <Row>
                <Col span="24" style="padding:20px 0 100px 0">
                <Button type="primary" @click="returnContent(1,'publicity')">保存</Button>
                <Button type="primary" @click="saveLocal">另存</Button>
                <Button type="primary" @click="returnContent(2,'publicity')">提交</Button>
                </Col>
            </Row>
        </Form>
        <div id='ueHtml' hidden>
            <!-- 另存文件使用 -->
        </div>
        </Card>
        <Modal v-model="modal1" width="400" footer-hide = true>
            <div style="height: 100px;padding: 25px 10px 25px 10px">
            <p  style="float: left;font-size: 13px;width: 90%;">
                <Icon type="ios-checkmark-circle" color="green" size="30" style="float: left;padding-right: 10px"/>
                 <b>发送成功，等待管理员通过审核后进行公示，不通过将会在草稿箱中</b>
            </p>
            <p style="float: left;padding-left: 40px"><span style="color: #FFC125">{{modalNum==4?0:modalNum}}s</span>将自动退出 </p>
            </div>
            <!-- <div slot="footer" >
                <Button type="primary" @click="modal1=false">确定</Button>
            </div> -->
        </Modal>
        <Spin size="large" fix v-if="spinShow" style="z-index:1200"></Spin>
    </div>

</template>

<script>
    import libs from "../libs/upload";
    import $ from '../libs/jqueryexport'
    import UE from '../components/ue.vue';
    import CityList from "../libs/city.js"
    import saveAs from 'file-saver';
    import '../libs/jquery.wordexport'

    export default {
        components: {UE},
        data() {
            return {
                shishi:'', // 上传地址
                ueHtmlData: '123',
                // 表单验证
                ruleValidate: {
                    Title: [
                        { required: true, message: '标题不能为空', trigger: 'blur' }
                    ],
                    ProjectType: [
                        { required: true, message: '项目类型不能为空', trigger: 'change' }
                    ],
                    ReportType: [
                        { required: true, message: '报告类型不能为空', trigger: 'change' }
                    ],
                    MProvince: [
                        { required: true, message: '请选择省份', trigger: 'change' }
                    ],
                    MCity: [
                        { required: true, message: '请选择城市', trigger: 'change' }
                    ],
                    MCounty: [
                        { required: true, message: '请选择县区', trigger: 'change' }
                    ],
                    // MAddress: [
                    //     { required: true, message: '详细地址不能为空', trigger: 'blur' }
                    // ],
                },
                // 上传
                upload_url: '',
                SessionID: '',
                uploadList: [],
                defaultList: [],
                uploadTaskID: '',
                fileID: '',
                spinShow: false,        //  点按钮后数据没回来不让点
                modal1:false,           //  提示几秒退出
                selectPublicLabel: '',  //  选择公示label-拼接title
                selectProjectName: '',  //  项目名字-拼接title
                MProvince: '',
                MCity: '',
                MCounty: '',
                //  UE设置
                ueditor: {
                    defaultMsg: '',
                    config: {
                        initialFrameWidth: null,
                        initialFrameHeight: 500,
                        wordCount: false,
                        elementPathEnabled: false,
                        toolbars: [[
                            // 'bold', 'italic', 'underline', 'fontborder', 'forecolor', 'backcolor', 'fontsize', 'strikethrough', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'emotion',
                            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', 'formatmatch', '|', 'forecolor', 'backcolor', 'selectall', 'cleardoc', '|',
                            'fontfamily', 'fontsize', '|',
                            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 
                            'emotion','date', 'time', 'spechars'
                        ]]
                    }
                },
                // 项目类型选择
                projectType: [
                    {
                        value: '0',
                        label: '第一次公示'
                    },
                    {
                        value: '1',
                        label: '第二次公示'
                    },
                    {
                        value: '2',
                        label: '验收公示'
                    },
                    {
                        value: '3',
                        label: '全本公示'
                    },
                    {
                        value: '4',
                        label: '其它公示'
                    },
                ],
                // 报告类型选择
                reportType: [
                    {
                        value: '报告表',
                        label: '报告表'
                    },
                    {
                        value: '报告书',
                        label: '报告书'
                    },
                    {
                        value: '现状评估报告',
                        label: '现状评估报告'
                    },
                    {
                        value: '规划',
                        label: '规划'
                    },
                    {
                        value: '验收',
                        label: '验收'
                    },
                ],
                // 省级联动
                cityList: CityList,         //  省
                cities: [],                 //  城市
                countys:[],                 //  县区
                // 表单内容
                publicity:{
                    Title: '',
                    ProjectType: '',
                    ReportType: '',
                    MProvince: '',
                    MCity: '',
                    MCounty: '',
                    MAddress: ''
                },
               /* enclosure:'aaa,aaa',//附件路径(每个附件路径间用“,”分隔)*/
                modalNum:4,
                canClick: true, //添加canClickeee
                uid:'',
                projectInfo: {},
                userPhoto: '',
           };
        },
        computed: { 
            eidtorId() {
                if(!this.$store.state.hotId) {
                    var storage=window.localStorage;
                    return storage.getItem("projectId");
                }else{
                    return this.$store.state.hotId;
                }

            }
        },
        watch: {
            'eidtorId'() {
                if(!this.eidtorId) {
                    this.$refs['publicity'].resetFields();
                    this.$refs.ue.editor.setContent(' ');
                }
                this.$refs.upload.clearFiles();
            },
             'MProvince'(){
                 this.change(this.MProvince,'isWatch');

             },
             'MCity'(){
                 this.changeCounty(this.MCity,'isWatch');
              }

        },
        beforeMount() {
            console.log(this.$route.query.uId)
            if(this.$route.query.ProjectId) {
                var ProjectId = this.$route.query.ProjectId
                this.$store.commit('toggleHotId','')  //防止进来有公示内容
                this.getProjectInfo(ProjectId)
                this.getUerInfo(this.$route.query.uId)                 // 获取登录人项目信息
            }
        },
        mounted() {
            if(this.eidtorId&&!this.$route.query.uId) {
                this.getDetails()
            }
            this.fileID = ''+new Date().getTime()
            this.shishi = libs.uploads();
        },
        methods: {
            // 获取登录人信息
            getUerInfo(uid) {
                console.log('获取登录人')
                axios.post('/member/findById',{Id:uid}).then(res=>{
                    console.log(res)
                    if(res._STATUS == 1) {
                        var userInfo = {
                            userName: res.member.realName,     //  用户名
                            publicSum: res.member.count,       //  用户发布次数
                            userPhoto: res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                        }
                        this.$store.commit('userPhoto',res.member.photo)
                        this.userPhoto =  res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                        this.$store.commit('logoutInfo',true)
                        this.$store.commit('loginUserInfo', userInfo)
                        localStorage.setItem('userInfo',JSON.stringify(userInfo))
                        localStorage.setItem('isLogin',true)
                    }else {
                        this.$router.push({name: 'HomePublic'})
                    }
                }).catch(err=>{
                    // console.log(err)
                })
            },
            // 获取登录人项目信息
            getProjectInfo(id) {
                console.log('获取项目')
                // axios.post('/projectInformation/findProjectByID',{id: 'c76202dd-a07a-4f3b-9d65-bfc7d76bfb8b'}).then(res=>{
                this.$post('/projectInformation/findProjectByID',{Id: id}).then(res=>{
                    console.log(res)
                    this.selectProjectName = res.info.ProjectName
                    this.$refs['publicity'].resetFields() //清空公示单选框内容
                    this.$nextTick(()=>{
                      this.publicity.Title = this.selectProjectName + this.selectPublicLabel
                    })
                    var projectInfo = {
                        ProjectName: res.info.ProjectName,            //  项目名称
                        BuildUnit: res.info.BuildUnit,                //  建设单位名称
                        BuildAddress: res.info.BuildAddress,          //..建设单位地址
                        Linkman: res.info.Linkman,                      //  建设单位联系人
                        TelNumber: res.info.TelNumber,                //  建设单位联系电话
                        FullName: res.FullName                          //  评价单位名称
                    }
                    console.log(projectInfo)
                    this.projectInfo = projectInfo
                    this.$store.commit('changeProjectInfo', projectInfo)
                    // sessionStorage.setItem("projectInfo", projectInfo);
                }).catch(err=>{
                    // console.log(err)
                })
            },
            // 获取详情
            getDetails() {
                this.$post('/publicity/findByPublicityId',{Id: this.eidtorId}).then(res=>{
                    this.publicity = res.publicity;
                    this.MProvince = res.publicity.MProvince;
                    this.MCity = res.publicity.MCity;
                    this.$refs.ue.editor.setContent(res.publicity.Content);
                    // this.$refs.ue.setUEContent(res.publicity.Content);
                    // this.ueditor.defaultMsg = res.publicity.Content;
                    var projectInfo = {
                        ProjectName: res.ProjectName?res.ProjectName:'',            //  项目名称
                        BuildUnit: res.BuildUnit,                //  建设单位名称
                        BuildAddress: res.BuildAddress,          //..建设单位地址
                        Linkman: res.Linkman,                      //  建设单位联系人
                        TelNumber: res.TelNumber,                //  建设单位联系电话
                        FullName: res.FullName                          //  评价单位名称
                    }
                    this.$store.commit('changeProjectInfo',projectInfo)
                    // 编缉回显上传文件
                    this.$post('.publicity.findByEnclosure',{Id:this.eidtorId}).then(res=>{
                        if(res._STATUS==1) {
                            // 上传文件列表
                            var PublicityEnclosure = res.PublicityEnclosure
                            if(PublicityEnclosure.length>0) {
                                PublicityEnclosure = PublicityEnclosure.map(el=>{
                                    var arr = el.Name.split('.')
                                    arr[0] = decodeURIComponent(arr[0])
                                    el.Name = arr.join('.')
                                    this.defaultList.push({
                                        name:el.Name,       //文件名
                                        url: el.Enclosure, // 文件下载地址
                                        id: el.Id,           //文件上传对应的id 删除要用
                                    })
                                })
                            }
                        }
                    })
                })
            },
            // 保存 提交按钮
            saveData(btn,url) {
                this.spinShow = true
                this.publicity.Content = this.$refs.ue.getUEContent()
                axios.post(url, {//暂时保存草稿
                    Id: this.eidtorId,
                    Title : this.publicity.Title,
                    ProjectType : this.publicity.ProjectType,
                    ReportType : this.publicity.ReportType,
                    MProvince : this.publicity.MProvince,
                    MCity : this.publicity.MCity,
                    MCounty: this.publicity.MCounty,
                    MAddress: this.publicity.MAddress,
                    Content : this.publicity.Content,
                    Enclosure : this.enclosure,
                    ProjectName : this.projectInfo.ProjectName,
                    BuildUnit : this.projectInfo.BuildUnit,
                    MailAddress : this.projectInfo.MailAddress,
                    Linkman : this.projectInfo.Linkman,
                    TelNumber : this.projectInfo.TelNumber,
                    FullName : this.projectInfo.FullName,
                    // industry : '所属行业...',
                    FileID: this.publicity.FileID?this.publicity.FileID:this.fileID,
                })
                .then((res) => {
                    if(btn == 2 ) {
                        this.spinShow = false
                        if(res._STATUS==1){
                            if(res._MESSAGE == '公示发布请求已提交,等待审核') {
                                this.modal1=true;
                                for(let i =0;i<3;i++){
                                    setTimeout(()=>{
                                        --this.modalNum
                                    },1000*i)
                                }
                                setTimeout(()=>{this.$nextTick(()=>{
                                    this.$router.push({name: 'MangePublic'})
                                    axios.post('/member/findById').then(res=>{
                                        var id = res.member.realName
                                        var userInfo = {
                                            userName: res.member.realName,     //  用户名
                                            publicSum: res.member.count,       //  用户发布次数
                                            userPhoto: res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()//用户头像    
                                        }
                                        this.$store.commit('userPhoto',res.member.photo)
                                        this.userPhoto =  res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                                        this.$store.commit('logoutInfo',true)
                                        this.$store.commit('loginUserInfo', userInfo)
                                        localStorage.setItem('userInfo',JSON.stringify(userInfo))
                                        localStorage.setItem('isLogin',true)
                                    }).catch(err=>{
                                        console.log(err)
                                    })
                                }) },3000)
                                setTimeout(()=>{
                                    this.modal1=false;
                                    this.modalNum=4;
                                    this.$router.push({name: 'MangePublic'})
                                },3000)
                            }else if(res._MESSAGE =='公示发布成功'  || res._MESSAGE =='公示更新发布成功' ) {
                                this.$Modal.success({
                                    title: res._MESSAGE,
                                    content: '发布成功，3秒跳转到管理页面！',
                                    onOk: ()=>{
                                        this.$nextTick(()=>{
                                            this.$router.push({name: 'MangePublic'})
                                            axios.post('/member/findById').then(res=>{
                                                var id = res.member.realName
                                                var userInfo = {
                                                    userName: res.member.realName,     //  用户名
                                                    publicSum: res.member.count,       //  用户发布次数
                                                    userPhoto: res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()//用户头像    
                                                }
                                                this.$store.commit('userPhoto',res.member.photo)
                                                this.userPhoto =  res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                                                this.$store.commit('logoutInfo',true)
                                                this.$store.commit('loginUserInfo', userInfo)
                                                localStorage.setItem('userInfo',JSON.stringify(userInfo))
                                                localStorage.setItem('isLogin',true)
                                            }).catch(err=>{
                                                console.log(err)
                                            })
                                        })
                                    }
                                });
                                setTimeout(()=>{
                                    this.$Modal.remove()
                                    this.$router.push({name: 'MangePublic'})
                                },3000)

                            }
                        }else if(res._STATUS==0) {
                            if(res._STATE==2) {
                                // setTimeout(()=>{
                                    this.$Modal.error({
                                        title: res._MESSAGE,
                                        content: '文本中不能包含 <span style="color:red">'+res.mgc.toString()+'</span>，请修改后，再次保存！'
                                    });
                                // },1000)
                                return ;
                            }else{
                                this.$Modal.error({
                                    title: res._MESSAGE,
                                    content: '公示发布请求提交失败!'
                                });
                                return ;
                            }
                        }
                    }else if(btn == 1) {
                        this.spinShow = false
                        if(res._STATUS==1) {
                            // console.log(res)
                            setTimeout(()=>{this.$Modal.success({
                                title: res._MESSAGE,
                                content: '点击确定跳转到草稿箱',
                                // 成功跳转管理
                                onOk: ()=> {
                                    this.$nextTick(()=>{
                                        this.$router.push({name: 'MangePublic'})
                                        axios.post('/member/findById').then(res=>{
                                            var id = res.member.realName
                                            var userInfo = {
                                                userName: res.member.realName,     //  用户名
                                                publicSum: res.member.count,       //  用户发布次数
                                                userPhoto: res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()//用户头像    
                                            }
                                            this.$store.commit('userPhoto',res.member.photo)
                                            this.userPhoto =  res.member.photo == ''? 'https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96' : 'https://static.anhuanjia.com/avatar/'+ res.member.photo + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                                            this.$store.commit('logoutInfo',true)
                                            this.$store.commit('loginUserInfo', userInfo)
                                            localStorage.setItem('userInfo',JSON.stringify(userInfo))
                                            localStorage.setItem('isLogin',true)
                                        }).catch(err=>{
                                            console.log(err)
                                        })
                                    })
                                    this.$router.push({name: 'MangePublic',params:{draftBtn:'primary'}})
                                }
                            });
                        },300)

                           /* this.$Modal.success({
                                title: res._MESSAGE,
                                content: '将跳转到管理页面'
                            });*/
                            // 成功跳转管理
                            /*this.$router.push({name: 'MangePublic'})*/
                        }else if(res._STATUS==0) {
                            if(res._STATE==2) {
                                setTimeout(()=>{
                                    this.$Modal.error({
                                        title: res._MESSAGE,
                                        content: '文本中不能包含 <span style="color:red">'+res.mgc.toString()+'</span>，请修改后，再次保存！'
                                    });
                                },1000)
                                return ;
                            }else{
                                this.$Modal.error({
                                    title: res._MESSAGE,
                                    content: '网络故障，请重试！'
                                });
                                return ;
                            }
                        }
                    }
                })
                .catch( (error)=> {
                    this.spinShow = false
                    // console.log(error)
                    this.$Notice.error({
                        title: '保存失败',
                        desc: ''
                    });
                });
            },
            // 点击时
            returnContent (btn,name) {
                this.$refs[name].validate((valid) => {
                    console.log(valid);
                    if (valid) {
                        let url ='';
                        if(btn==1){
                            url = '/publicity/saveOrUpdatePublicity';
                            this.$Modal.confirm({
                                title: '确认要保存？',
                                content: '<p>点击确认会保存草稿中！</p>',
                                onOk: () => {
                                    // 确认后下一次事件执行
                                    this.$nextTick(()=>{
                                        this.saveData(btn,url)
                                    })
                                    return ;
                                },
                                onCancel: () => {
                                    this.$Message.info('点击取消按钮');
                                    return ;
                                }
                            });
                        }else if(btn==2){
                            // console.log(btn)
                            url = '/publicity/ReleasePublicity';
                            this.saveData(btn,url)
                        }
                    } else {
                        this.$Message.error('请把信息填写完整！');
                        return ;
                    }
                })

            },
            instance(type) {
                const title = '发送成功,等管理员审核通过后进行公示，不通过公示将会在草稿箱中。';
                const content = '<p>3s后自动退出</p>';
                 this.$Modal.success({
                    title: title,
                    content: content
                });
                setTimeout(() =>{
                    this.$Modal.remove();
                },3000)
            },
            // 选择省份
            change(val,isWatch){
                if(!isWatch){
                    this.publicity.MCity = '';
                }
                for(var i=0; i<this.cityList.length; i++){
                    if(val == this.cityList[i].name ){
                        this.cities = this.cityList[i].cityList
                    }
                }
            },
            changeCounty(val,isWatch) {
                if(!isWatch){
                    this.publicity.MCounty = '';
                    this.countys = []
                }
               for(var i=0; i<this.cities.length; i++){
                    if(val == this.cities[i].name ){
                        this.countys = this.cities[i].areaList
                    }
                }
            },
            changeType(val){
                // 为空不执行下面的
                if(!val) return;
                this.projectType.forEach(item=>{
                    if(item.value == val){
                        this.selectPublicLabel = item.label
                        this.publicity.Title = this.selectProjectName + this.selectPublicLabel
                    }
                })
                this.$post('/publicity/getPublicityType', {
                    PublicityType:val,
                }).then( (res) => {
                      if(res._STATUS==1) {
                        // this.publicityType = res.publicityType;
                          this.$refs.ue.editor.setContent(res.publicityType.content);
                      }
                }).catch( (error)=> {
                  // console.log(error);
                });
            },
            // 另存本地
            saveLocal() {
                this.ueHtmlData = this.$refs.ue.getUEContent()
                $('#ueHtml').html(this.ueHtmlData)
                $('#ueHtml').wordExport(this.publicity.Title)
            //    var FileSaver = require('file-saver');
            //     var file = new File([this.$refs.ue.getUEContent()], "公示草稿.docx", {type: "text/plain;charset=utf-8"});
            //     FileSaver.saveAs(file);
            // //    console.log(this.$refs.ue.getUEContent())
            },
            // 获取sessionID
            getSessionID () {
                let that = this, params = {};
                axios.post(libs.uploads() + 'UploadExecutor/getSessionID').then(res => {
                    this.SessionID = res.SessionID;
                    this.uploadTaskID = (new Date().getTime() + '' + res.SessionID);
                });
                // console.log('获取到session')
            },
            // 附件上传成功
            uploadSuccess(res, file, fileList) {
                // 上传成功后查询上传文件
                if(this.eidtorId) {
                    var Id = this.eidtorId
                    this.$post('publicity.findByEnclosure',{Id}).then(res=>{
                    // console.log(res)
                    if(res._STATUS==1) {
                        file.enclosure = res.PublicityEnclosure[0].enclosure    // 文件下载地址
                        file.id =  res.PublicityEnclosure[0].id                 //文件上传对应的id 删除要用
                        // console.log(fileList)
                    }
                })
                }else  {
                    var FileId = this.fileID
                    this.$post('publicity.findByEnclosure',{FileId}).then(res=>{
                    // console.log(res)
                    if(res._STATUS==1) {
                        file.enclosure = res.PublicityEnclosure[0].enclosure    // 文件下载地址
                        file.id =  res.PublicityEnclosure[0].id                 //文件上传对应的id 删除要用
                        // console.log(fileList)
                    }
                })
                }
                
            },
            // 删除上传文件
            removeFile(file,fileList) {
                axios.post('/publicity/delete',{Id: file.id}).then(res=>{
                    // console.log(res)
                    if(res._STATUS==1) {
                        this.$Message.success(res._MESSAGE)
                    }
                })
            },
            // 上传失败
            uploadError(err,file) {
                this.$Message.error('上传失败');
                // console.log(err)
            },
        },

    };
</script>

<style lang="less">
    .vertical-center-modal{
        display: flex;
        align-items: center;
        justify-content: center;

        .ivu-modal{
            top: 0;
        }
    }
    .twoPublic {

        .ivu-card-head {
            background: #f8f8f9;
        }

        .ivu-card-body {
            text-align: center;

            input {
                width: 100%;
            }

            .other-Col {
                position: relative;
                z-index: 100;

                // .ivu-row {
                //     // margin: 10px auto;
                //     // width: 85%;
                // }
            }
        }

        #editor1 {
            position: relative;
            z-index: 1;
        }

    }
</style>
